package com.xian.rooms.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.xian.common.annotation.Log;
import com.xian.common.core.controller.BaseController;
import com.xian.common.core.domain.AjaxResult;
import com.xian.common.enums.BusinessType;
import com.xian.rooms.domain.HotelRoomsir;
import com.xian.rooms.service.IHotelRoomsService;
import com.xian.common.utils.poi.ExcelUtil;
import com.xian.common.core.page.TableDataInfo;

/**
 * 房间信息Controller
 * 
 * @author ruoyi
 * @date 2025-04-10
 */
@RestController
@RequestMapping("/rooms/rooms")
public class HotelRoomsController extends BaseController
{
    @Autowired
    private IHotelRoomsService hotelRoomsService;

    /**
     * 查询房间信息列表
     */
    @PreAuthorize("@ss.hasPermi('rooms:rooms:list')")
    @GetMapping("/list")
    public TableDataInfo list(HotelRoomsir hotelRoomsir)
    {
        startPage();
        List<HotelRoomsir> list = hotelRoomsService.selectHotelRoomsList(hotelRoomsir);
        return getDataTable(list);
    }

    /**
     * 导出房间信息列表
     */
    @PreAuthorize("@ss.hasPermi('rooms:rooms:export')")
    @Log(title = "房间信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HotelRoomsir hotelRoomsir)
    {
        List<HotelRoomsir> list = hotelRoomsService.selectHotelRoomsList(hotelRoomsir);
        ExcelUtil<HotelRoomsir> util = new ExcelUtil<HotelRoomsir>(HotelRoomsir.class);
        util.exportExcel(response, list, "房间信息数据");
    }

    /**
     * 获取房间信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('rooms:rooms:query')")
    @GetMapping(value = "/{roomId}")
    public AjaxResult getInfo(@PathVariable("roomId") Long roomId)
    {
        return success(hotelRoomsService.selectHotelRoomsByRoomId(roomId));
    }

    /**
     * 新增房间信息
     */
    @PreAuthorize("@ss.hasPermi('rooms:rooms:add')")
    @Log(title = "房间信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HotelRoomsir hotelRoomsir)
    {
        return toAjax(hotelRoomsService.insertHotelRooms(hotelRoomsir));
    }

    /**
     * 修改房间信息
     */
    @PreAuthorize("@ss.hasPermi('rooms:rooms:edit')")
    @Log(title = "房间信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HotelRoomsir hotelRoomsir)
    {
        return toAjax(hotelRoomsService.updateHotelRooms(hotelRoomsir));
    }

    /**
     * 删除房间信息
     */
    @PreAuthorize("@ss.hasPermi('rooms:rooms:remove')")
    @Log(title = "房间信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{roomIds}")
    public AjaxResult remove(@PathVariable Long[] roomIds)
    {
        return toAjax(hotelRoomsService.deleteHotelRoomsByRoomIds(roomIds));
    }
}
